package cn.outsourcing.supermarket.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * @author gzkemays
 * @since 2021/11/3 19:32
 */
public class OrderGoodsProvider {
  public String getOrderGoodsDetails() {
    return new SQL() {
      {
        SELECT("*")
            .FROM("hiolabs_order_goods hog")
            .LEFT_OUTER_JOIN("hiolabs_product hp on hp.id = hog_product_id")
            .WHERE("hog.order_id = ${orderId} and hog.is_delete = 0");
      }
    }.toString();
  }

  public String getProductSpecificationByGoodsId() {
    return new SQL() {
      {
        SELECT("*")
            .FROM("hiolabs_product hp")
            .LEFT_OUTER_JOIN(
                "hiolabs_goods_specification hgs on hgs.id = hp.goods_specification_ids")
            .WHERE("hp.is_delete = 0", "hgs.is_delete = 0", "hp.goods_id in (${goodsIds})");
      }
    }.toString();
  }
}
